<?php

include_once "db.php";
include_once "checksession.php"; 

 class Pager  
   {  
       function getPagerData($numHits, $limit, $page)  
       {  
           $numHits  = (int) $numHits;  
           $limit    = max((int) $limit, 1);  
           $page     = (int) $page;  
           $numPages = ceil($numHits / $limit);  

           $page = max($page, 1);  
           $page = min($page, $numPages);  

           $offset = ($page - 1) * $limit;  

           $ret = new stdClass;  

           $ret->offset   = $offset;  
           $ret->limit    = $limit;  
           $ret->numPages = $numPages;  
           $ret->page     = $page;  

           return $ret;  
       }  
   }  
	
	$query = mysql_query("select count(*) from resolution_notes WHERE resolution_notes.transfer_to = 'admissions'");
	$admissionsTotal = mysql_result($query, 0, 0);
	
	$query = mysql_query("select count(*) from resolution_notes WHERE resolution_notes.transfer_to = 'counseling'");
	$counselingTotal = mysql_result($query, 0, 0);
	
	$query = mysql_query("select count(*) from resolution_notes WHERE resolution_notes.transfer_to = 'admissions sup'");
	$adsup_transferTotal = mysql_result($query, 0, 0);
	
	$query = mysql_query("select count(*) from resolution_notes WHERE resolution_notes.transfer_to = 'cashiers'");
	$cashiers_transferTotal = mysql_result($query, 0, 0);
	
	$query = mysql_query("select count(*) from resolution_notes WHERE resolution_notes.transfer_to = 'faculty staff HD'");
	$faculty_transferTotal = mysql_result($query, 0, 0);
	
	$query = mysql_query("select count(*) from resolution_notes WHERE resolution_notes.transfer_to = 'financial aid'");
	$financial_transferTotal = mysql_result($query, 0, 0);
	
	$query = mysql_query("select count(*) from resolution_notes WHERE resolution_notes.transfer_to = 'other'");
	$other_transferTotal = mysql_result($query, 0, 0);
	$total_transfers = $admissionsTotal + $counselingTotal + $adsup_transferTotal + $cashiers_transferTotal + $faculty_transferTotal + $financial_transferTotal + $other_transferTotal;
	
	
	
	
	$sp09results = mysql_query("select count(*) from Calls WHERE Calls.request_date > '2009-01-01%' and Calls.request_date < '2009-05-19%'"); 
	$su09results = mysql_query("select count(*) from Calls WHERE Calls.request_date > '2009-05-20%' and Calls.request_date < '2009-08-22%'"); 
	$fa09results = mysql_query("select count(*) from Calls WHERE Calls.request_date > '2009-08-23%' and Calls.request_date < '2009-12-24%'");  
	$sp10results = mysql_query("select count(*) from Calls WHERE Calls.request_date > '2010-01-02%'   AND Calls.request_date < '2010-5-19%'"); 
	$su10results = mysql_query("select count(*) from Calls WHERE Calls.request_date > '2010-05-07%'   AND Calls.request_date < '2010-08-22%'");
	$fa10results = mysql_query("select count(*) from Calls WHERE Calls.request_date > '2010-08-16%'   AND Calls.request_date < '2010-12-31%'");
	$sp11results = mysql_query("select count(*) from Calls WHERE Calls.request_date > '2011-1-01%'   AND Calls.request_date < '2011-5-21%'");
	$Phoneresults = mysql_query("select count(*) from resolution_notes WHERE resolution_notes.note_date > '2010-12-15%'   AND contact_type='phone'");
	
	
	$sp09total = mysql_result($sp09results, 0, 0);  
	$fa09total = mysql_result($fa09results, 0, 0);
	$su09total = mysql_result($su09results, 0, 0);
	$sp10total = mysql_result($sp10results, 0, 0);
	$su10total = mysql_result($su10results, 0, 0);
	$fa10total = mysql_result($fa10results, 0, 0);
	$sp11total = mysql_result($sp11results, 0, 0);
	$Phonetotal = mysql_result($Phoneresults, 0 , 0);
	
	
	
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Online College Helpdesk - Statistics</title>
<link href="meta-style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<?php
include_once "topnav.php";
?>
<div align="center">
<table width="500" border="1" cellpadding="3" cellspacing="0" bordercolor="#FF0000">
<th bgcolor="#006699"><font color="#ffffff"> Call transfered Start date: Dec 15th 2010</font></th>
<th bgcolor="#006699"></th>
<tr align="right" valign="bottom" > 	
      <td align="right"><strong>
     
    Total transfers to Admissions office</strong></td>
	<td><strong> 
<?php	  
echo $admissionsTotal; 
?> </strong>
</td>
  </tr>
  
     <tr align="right" valign="bottom" >
      <td align="right"><strong>	
	  Total transfers to counseling </strong></td>
	<td><strong>
<?php	  
echo $counselingTotal; 
?> </strong>
</td>
  </tr>
  
<tr align="right" valign="bottom" >
      <td align="right"><strong>	
    Total transfers to other extensions</strong></td>
	<td><strong>
<?php	  
echo $other_transferTotal; 
?> </strong>
</td>
      </tr>
      <tr align="right" valign="bottom" >
      <td align="right"><strong>	
    Total transfers to admissions supervisor </strong></td>
	<td><strong>
<?php	  
echo $adsup_transferTotal; 
?> </strong>
</td>
      </tr>
      
       <tr align="right" valign="bottom" >
      <td align="right"><strong>	
    Total transfers to cashiers </strong></td>
	<td><strong>
<?php	  
echo $cashiers_transferTotal;
?> </strong>
</td>
      </tr>
      
      <tr align="right" valign="bottom" >
      <td align="right"><strong>	
    Total transfers to financial aid </strong></td>
	<td><strong>
<?php	  
echo $financial_transferTotal;
?> </strong>
</td>
      </tr>
      
        
      <tr align="right" valign="bottom" >
      <td align="right"><strong>	
    Total transfers to faculty help desk </strong></td>
	<td><strong>
<?php	  
echo $faculty_transferTotal;
?> </strong>
</td>
      </tr>
      
          <tr align="right" valign="bottom" >
      <td align="right"><strong>	
    Total transfers since 12/15/2010 </strong></td>
	<td><strong>
<?php	  
echo $total_transfers;
?> </strong>
</td>
      </tr>
      
      
 </table>	
 <br />
 
 <table width="500" border="1" cellpadding="3" cellspacing="0" bordercolor="#FF0000">
<tr align="right" valign="bottom" >
      <td align="right"><strong>	
    Total number of Phone calls since 12/15/2010  </strong></td>
	<td><strong><font color="#FF0000">  
<?php	  
echo $Phonetotal; 
?> </strong>
</font></td>
  </tr>
  </table>
  
 <br>
<table width="500" border="1" cellpadding="3" cellspacing="0" bordercolor="#FF0000">
<tr align="right" valign="bottom" >
      <td align="right"><strong>	
    Total number of database entries for Spring 09 (1-01-09- 5-19-09) = </strong></td>
	<td><strong><font color="#FF0000">  
<?php	  
echo $sp09total; 
?> </strong>
</font></td>
  </tr>
  
     <tr align="right" valign="bottom" >
      <td align="right"><strong>	
	  Total number of database entries for Summer 09 (5-20-09- 8-22-09) = </strong></td>
	<td><strong><font color="#FF0000">  
<?php	  
echo $su09total; 
?> </strong>
</font></td>
  </tr>
  
<tr align="right" valign="bottom" >
      <td align="right"><strong>	
    Total number of database entries for Fall 09 (8-23-09 to 12-24-09) = </strong></td>
	<td><strong><font color="#FF0000">  
<?php	  
echo $fa09total; 
?> </strong>
</font></td>
      </tr>
      
       <tr align="right" valign="bottom" >
      <td align="right"><strong>	
	  Total number of database entries for Spring 10 (1-02-10 - 5-19-10) = </strong></td>
	<td><strong><font color="#FF0000">  
<?php	  
echo $sp10total; 
?> </strong>
</font></td>
  </tr>
  
       <tr align="right" valign="bottom" >
      <td align="right"><strong>	
	  Total number of database entries for Summer 10 (5-07-10 - 8-22-10) = </strong></td>
	<td><strong><font color="#FF0000">  
<?php	  
echo $su10total; 
?> </strong>
</font></td>
  </tr>
  
       <tr align="right" valign="bottom" >
      <td align="right"><strong>	
	  Total number of database entries for Fall 10 (8-16-10 - 12-31-10) = </strong></td>
	<td><strong><font color="#FF0000">  
<?php	  
echo $fa10total; 
?> </strong>
</font></td>
  </tr>
  
   <tr align="right" valign="bottom" >
      <td align="right"><strong>	
	  Total number of database entries for Spring 11 (1-1-2011 - 5-31-2011) = </strong></td>
	<td><strong><font color="#FF0000">  
<?php	  
echo $sp11total; 
?> </strong>
</font></td>
  </tr>
  
  </table>		 
		 
<br />
<?php

//begin queries for number of calls, emails by problem type
	//moodle
	$sp11resultsmoodle = mysql_query("select count(*) from Calls WHERE problem_type='23' AND Calls.request_date > '2011-01-1%' AND Calls.request_date < '2011-05-31%'");
	$sp11moodletotal = mysql_result($sp11resultsmoodle, 0, 0);
	//campus card
	$sp11resultscc = mysql_query("select count(*) from Calls WHERE problem_type='24' AND Calls.request_date > '2011-01-1%' AND Calls.request_date < '2011-05-31%'");
	$sp11cctotal = mysql_result($sp11resultscc, 0, 0);
	//sbcc wireless
	$sp11resultswireless = mysql_query("select count(*) from Calls WHERE problem_type='26' AND Calls.request_date > '2011-01-1%' AND Calls.request_date < '2011-05-31%'");
	$sp11wirelesstotal = mysql_result($sp11resultswireless, 0, 0);
	//PL Error message in Browser
	$sp11resultsPLerror = mysql_query("select count(*) from Calls WHERE problem_type='7' AND Calls.request_date > '2011-01-1%' AND Calls.request_date < '2011-05-31%'");
	$sp11PLerrortotal = mysql_result($sp11resultsPLerror, 0, 0);
	//sbcc Registration/Add problem
	$sp11resultsreg = mysql_query("select count(*) from Calls WHERE problem_type='8' AND Calls.request_date > '2011-01-1%' AND Calls.request_date < '2011-05-31%'");
	$sp11regtotal = mysql_result($sp11resultsreg, 0, 0);
	//sbcc PL Problem - email, chat, etc
	$sp11resultsplprob = mysql_query("select count(*) from Calls WHERE problem_type='11' AND Calls.request_date > '2011-01-1%' AND Calls.request_date < '2011-05-31%'");
	$sp11plprobtotal = mysql_result($sp11resultsplprob, 0, 0);
	//sbcc other
	$sp11resultsother = mysql_query("select count(*) from Calls WHERE problem_type='13' AND Calls.request_date > '2011-01-1%' AND Calls.request_date < '2011-05-31%'");
	$sp11othertotal = mysql_result($sp11resultsother, 0, 0);
	//sbcc PL account locked disabled
	$sp11resultspllocked = mysql_query("select count(*) from Calls WHERE problem_type='22' AND Calls.request_date > '2011-01-1%' AND Calls.request_date < '2011-05-31%'");
	$sp11pllockedtotal = mysql_result($sp11resultspllocked, 0, 0);
	//sbcc PL Login 
	$sp11resultspllogin = mysql_query("select count(*) from Calls WHERE problem_type='18' AND Calls.request_date > '2011-01-1%' AND Calls.request_date < '2011-05-31%'");
	$sp11pllogintotal = mysql_result($sp11resultspllogin, 0, 0);
	//sbcc SQ reset
	$sp11resultsplsq = mysql_query("select count(*) from Calls WHERE problem_type='21' AND Calls.request_date > '2011-01-1%' AND Calls.request_date < '2011-05-31%'");
	$sp11plsqtotal = mysql_result($sp11resultsplsq, 0, 0);

?>
 <table width="50%" border="1" cellpadding="2" cellspacing="0" bordercolor="#000000">
   <tr>
     <td colspan="2"><span class="title">Statistics for Spring 2011 - Problem Type &amp; Total number of calls/emails for<strong> (1/1/2011 - 5/31/2011) </strong></span></td>
   </tr>
  
     <tr>
     <td width="64%">Moodle Technical Issue</td>
     <td width="36%"><?php echo $sp11moodletotal ?></td>
   </tr>
   <tr>
     <td>Campus Card</td>
     <td><?php echo $sp11cctotal ?></td>
   </tr>
   <tr>
     <td>SBCC Wireless</td>
     <td><?php echo $sp11wirelesstotal ?></td>
   </tr>
   <tr>
     <td>Error Message in Browser - Pipeline</td>
     <td><?php echo $sp11PLerrortotal ?></td>
   </tr>
   <tr>
     <td>Registration/Add Problem</td>
     <td><?php echo $sp11regtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Problem (email, groups, chat, ect)</td>
     <td><?php echo $sp11plprobtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Account Locked or Disabled</td>
     <td><?php echo $sp11pllockedtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Secret Question Resets</td>
     <td><?php echo $sp11plsqtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Login Problem</td>
     <td><?php echo $sp11pllogintotal ?></td>
   </tr>
   <tr>
     <td>Other</td>
     <td><?php echo $sp11othertotal ?></td>
   </tr>
 </table>

 <br />


<?php

//begin queries for number of calls, emails by problem type
	//moodle
	$fa10resultsmoodle = mysql_query("select count(*) from Calls WHERE problem_type='23' AND Calls.request_date > '2010-08-16%' AND Calls.request_date < '2010-12-31%'");
	$fa10moodletotal = mysql_result($fa10resultsmoodle, 0, 0);
	//campus card
	$fa10resultscc = mysql_query("select count(*) from Calls WHERE problem_type='24' AND Calls.request_date > '2010-08-16%' AND Calls.request_date < '2010-12-31%'");
	$fa10cctotal = mysql_result($fa10resultscc, 0, 0);
	//sbcc wireless
	$fa10resultswireless = mysql_query("select count(*) from Calls WHERE problem_type='26' AND Calls.request_date > '2010-08-16%' AND Calls.request_date < '2010-12-31%'");
	$fa10wirelesstotal = mysql_result($fa10resultswireless, 0, 0);
	//PL Error message in Browser
	$fa10resultsPLerror = mysql_query("select count(*) from Calls WHERE problem_type='7' AND Calls.request_date > '2010-08-16%' AND Calls.request_date < '2010-12-31%'");
	$fa10PLerrortotal = mysql_result($fa10resultsPLerror, 0, 0);
	//sbcc Registration/Add problem
	$fa10resultsreg = mysql_query("select count(*) from Calls WHERE problem_type='8' AND Calls.request_date > '2010-08-16%' AND Calls.request_date < '2010-12-31%'");
	$fa10regtotal = mysql_result($fa10resultsreg, 0, 0);
	//sbcc PL Problem - email, chat, etc
	$fa10resultsplprob = mysql_query("select count(*) from Calls WHERE problem_type='11' AND Calls.request_date > '2010-08-16%' AND Calls.request_date < '2010-12-31%'");
	$fa10plprobtotal = mysql_result($fa10resultsplprob, 0, 0);
	//sbcc other
	$fa10resultsother = mysql_query("select count(*) from Calls WHERE problem_type='13' AND Calls.request_date > '2010-08-16%' AND Calls.request_date < '2010-12-31%'");
	$fa10othertotal = mysql_result($fa10resultsother, 0, 0);
	//sbcc PL account locked disabled
	$fa10resultspllocked = mysql_query("select count(*) from Calls WHERE problem_type='22' AND Calls.request_date > '2010-08-16%' AND Calls.request_date < '2010-12-31%'");
	$fa10pllockedtotal = mysql_result($fa10resultspllocked, 0, 0);
	//sbcc PL Login 
	$fa10resultspllogin = mysql_query("select count(*) from Calls WHERE problem_type='18' AND Calls.request_date > '2010-08-16%' AND Calls.request_date < '2010-12-31%'");
	$fa10pllogintotal = mysql_result($fa10resultspllogin, 0, 0);
	//sbcc SQ reset
	$fa10resultsplsq = mysql_query("select count(*) from Calls WHERE problem_type='21' AND Calls.request_date > '2010-08-16%' AND Calls.request_date < '2010-12-31%'");
	$fa10plsqtotal = mysql_result($fa10resultsplsq, 0, 0);

?>
 <table width="50%" border="1" cellpadding="2" cellspacing="0" bordercolor="#000000">
   <tr>
     <td colspan="2"><span class="title">Statistics for Fall 2010 - Problem Type &amp; Total number of calls/emails for<strong> (8/16/2010 - 12/31/10) </strong></span></td>
   </tr>
  
     <tr>
     <td width="64%">Moodle Technical Issue</td>
     <td width="36%"><?php echo $fa10moodletotal ?></td>
   </tr>
   <tr>
     <td>Campus Card</td>
     <td><?php echo $fa10cctotal ?></td>
   </tr>
   <tr>
     <td>SBCC Wireless</td>
     <td><?php echo $fa10wirelesstotal ?></td>
   </tr>
   <tr>
     <td>Error Message in Browser - Pipeline</td>
     <td><?php echo $fa10PLerrortotal ?></td>
   </tr>
   <tr>
     <td>Registration/Add Problem</td>
     <td><?php echo $fa10regtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Problem (email, groups, chat, ect)</td>
     <td><?php echo $fa10plprobtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Account Locked or Disabled</td>
     <td><?php echo $fa10pllockedtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Secret Question Resets</td>
     <td><?php echo $fa10plsqtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Login Problem</td>
     <td><?php echo $fa10pllogintotal ?></td>
   </tr>
   <tr>
     <td>Other</td>
     <td><?php echo $fa10othertotal ?></td>
   </tr>
 </table>

 <br />








  <?php

//begin queries for number of calls, emails by problem type
	//moodle
	$su10resultsmoodle = mysql_query("select count(*) from Calls WHERE problem_type='23' AND Calls.request_date > '2010-05-07%'  AND Calls.request_date < '2010-8-22%'");
	$su10moodletotal = mysql_result($su10resultsmoodle, 0, 0);
	//campus card
	$su10resultscc = mysql_query("select count(*) from Calls WHERE problem_type='24' AND Calls.request_date > '2010-05-07%'  AND Calls.request_date < '2010-8-22%'");
	$su10cctotal = mysql_result($su10resultscc, 0, 0);
	//sbcc wireless
	$su10resultswireless = mysql_query("select count(*) from Calls WHERE problem_type='26' AND Calls.request_date > '2010-05-07%'  AND Calls.request_date < '2010-8-22%'");
	$su10wirelesstotal = mysql_result($su10resultswireless, 0, 0);
	//PL Error message in Browser
	$su10resultsPLerror = mysql_query("select count(*) from Calls WHERE problem_type='7' AND Calls.request_date > '2010-05-07%'  AND Calls.request_date < '2010-8-22%'");
	$su10PLerrortotal = mysql_result($su10resultsPLerror, 0, 0);
	//sbcc Registration/Add problem
	$su10resultsreg = mysql_query("select count(*) from Calls WHERE problem_type='8' AND Calls.request_date > '2010-05-07%'  AND Calls.request_date < '2010-8-22%'");
	$su10regtotal = mysql_result($su10resultsreg, 0, 0);
	//sbcc PL Problem - email, chat, etc
	$su10resultsplprob = mysql_query("select count(*) from Calls WHERE problem_type='11' AND Calls.request_date > '2010-05-07%'  AND Calls.request_date < '2010-8-22%'");
	$su10plprobtotal = mysql_result($su10resultsplprob, 0, 0);
	//sbcc other
	$su10resultsother = mysql_query("select count(*) from Calls WHERE problem_type='13' AND Calls.request_date > '2010-05-07%'  AND Calls.request_date < '2010-8-22%'");
	$su10othertotal = mysql_result($su10resultsother, 0, 0);
	//sbcc PL account locked disabled
	$su10resultspllocked = mysql_query("select count(*) from Calls WHERE problem_type='22' AND Calls.request_date > '2010-05-07%'  AND Calls.request_date < '2010-8-22%'");
	$su10pllockedtotal = mysql_result($su10resultspllocked, 0, 0);
	//sbcc PL Login 
	$su10resultspllogin = mysql_query("select count(*) from Calls WHERE problem_type='18' AND Calls.request_date > '2010-05-07%'  AND Calls.request_date < '2010-8-22%'");
	$su10pllogintotal = mysql_result($su10resultspllogin, 0, 0);
	//sbcc SQ reset
	$su10resultsplsq = mysql_query("select count(*) from Calls WHERE problem_type='21' AND Calls.request_date > '2010-05-07%'  AND Calls.request_date < '2010-8-22%'");
	$su10plsqtotal = mysql_result($su10resultsplsq, 0, 0);

?>
 <table width="50%" border="1" cellpadding="2" cellspacing="0" bordercolor="#000000">
   <tr>
     <td colspan="2"><span class="title">Statistics for Summer 2010 - Problem Type &amp; Total number of calls/emails for<strong> (5-07-10 - 8-22-10) </strong></span></td>
   </tr>
  
     <tr>
     <td width="64%">Moodle Technical Issue</td>
     <td width="36%"><?php echo $su10moodletotal ?></td>
   </tr>
   <tr>
     <td>Campus Card</td>
     <td><?php echo $su10cctotal ?></td>
   </tr>
   <tr>
     <td>SBCC Wireless</td>
     <td><?php echo $su10wirelesstotal ?></td>
   </tr>
   <tr>
     <td>Error Message in Browser - Pipeline</td>
     <td><?php echo $su10PLerrortotal ?></td>
   </tr>
   <tr>
     <td>Registration/Add Problem</td>
     <td><?php echo $su10regtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Problem (email, groups, chat, ect)</td>
     <td><?php echo $su10plprobtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Account Locked or Disabled</td>
     <td><?php echo $su10pllockedtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Secret Question Resets</td>
     <td><?php echo $su10plsqtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Login Problem</td>
     <td><?php echo $su10pllogintotal ?></td>
   </tr>
   <tr>
     <td>Other</td>
     <td><?php echo $su10othertotal ?></td>
   </tr>
 </table>
 <br />
  <?php

//begin queries for number of calls, emails by problem type
	//moodle
	$sp10resultsmoodle = mysql_query("select count(*) from Calls WHERE problem_type='23' AND Calls.request_date > '2010-01-02%'  AND Calls.request_date < '2010-5-19%'");
	$sp10moodletotal = mysql_result($sp10resultsmoodle, 0, 0);
	//campus card
	$sp10resultscc = mysql_query("select count(*) from Calls WHERE problem_type='24' AND Calls.request_date > '2010-01-02%'  AND Calls.request_date < '2010-5-19%'");
	$sp10cctotal = mysql_result($sp10resultscc, 0, 0);
	//sbcc wireless
	$sp10resultswireless = mysql_query("select count(*) from Calls WHERE problem_type='26' AND Calls.request_date > '2010-01-02%'  AND Calls.request_date < '2010-5-19%'");
	$sp10wirelesstotal = mysql_result($sp10resultswireless, 0, 0);
	//PL Error message in Browser
	$sp10resultsPLerror = mysql_query("select count(*) from Calls WHERE problem_type='7' AND Calls.request_date > '2010-01-02%'  AND Calls.request_date < '2010-5-19%'");
	$sp10PLerrortotal = mysql_result($sp10resultsPLerror, 0, 0);
	//sbcc Registration/Add problem
	$sp10resultsreg = mysql_query("select count(*) from Calls WHERE problem_type='8' AND Calls.request_date > '2010-01-02%'  AND Calls.request_date < '2010-5-19%'");
	$sp10regtotal = mysql_result($sp10resultsreg, 0, 0);
	//sbcc PL Problem - email, chat, etc
	$sp10resultsplprob = mysql_query("select count(*) from Calls WHERE problem_type='11' AND Calls.request_date > '2010-01-02%'  AND Calls.request_date < '2010-5-19%'");
	$sp10plprobtotal = mysql_result($sp10resultsplprob, 0, 0);
	//sbcc other
	$sp10resultsother = mysql_query("select count(*) from Calls WHERE problem_type='13' AND Calls.request_date > '2010-01-02%'  AND Calls.request_date < '2010-5-19%'");
	$sp10othertotal = mysql_result($sp10resultsother, 0, 0);
	//sbcc PL account locked disabled
	$sp10resultspllocked = mysql_query("select count(*) from Calls WHERE problem_type='22' AND Calls.request_date > '2010-01-02%'  AND Calls.request_date < '2010-5-19%'");
	$sp10pllockedtotal = mysql_result($sp10resultspllocked, 0, 0);
	//sbcc PL Login 
	$sp10resultspllogin = mysql_query("select count(*) from Calls WHERE problem_type='18' AND Calls.request_date > '2010-01-02%'  AND Calls.request_date < '2010-5-19%'");
	$sp10pllogintotal = mysql_result($sp10resultspllogin, 0, 0);
	//sbcc SQ reset
	$sp10resultsplsq = mysql_query("select count(*) from Calls WHERE problem_type='21' AND Calls.request_date > '2010-01-02%'  AND Calls.request_date < '2010-5-19%'");
	$sp10plsqtotal = mysql_result($sp10resultsplsq, 0, 0);

?>
 <table width="50%" border="1" cellpadding="2" cellspacing="0" bordercolor="#000000">
   <tr>
     <td colspan="2"><span class="title">Statistics for Spring 2010 - Problem Type &amp; Total number of calls/emails for<strong> (1-02-10 - 5-19-10) </strong></span></td>
   </tr>
   <tr>
     <td colspan="2"><em><strong>Note that this was the first semester we logged CALLS and emails. Previously, all that was logged in dbse was emails.</strong></em></td>
   </tr>
     <tr>
     <td width="64%">Moodle Technical Issue</td>
     <td width="36%"><?php echo $sp10moodletotal ?></td>
   </tr>
   <tr>
     <td>Campus Card</td>
     <td><?php echo $sp10cctotal ?></td>
   </tr>
   <tr>
     <td>SBCC Wireless</td>
     <td><?php echo $sp10wirelesstotal ?></td>
   </tr>
   <tr>
     <td>Error Message in Browser - Pipeline</td>
     <td><?php echo $sp10PLerrortotal ?></td>
   </tr>
   <tr>
     <td>Registration/Add Problem</td>
     <td><?php echo $sp10regtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Problem (email, groups, chat, ect)</td>
     <td><?php echo $sp10plprobtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Account Locked or Disabled</td>
     <td><?php echo $sp10pllockedtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Secret Question Resets</td>
     <td><?php echo $sp10plsqtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Login Problem</td>
     <td><?php echo $sp10pllogintotal ?></td>
   </tr>
   <tr>
     <td>Other</td>
     <td><?php echo $sp10othertotal ?></td>
   </tr>
 </table>
 <br />
 <?php

//begin queries for number of calls, emails by problem type
	//moodle
	$fa09resultsmoodle = mysql_query("select count(*) from Calls WHERE problem_type='23' AND Calls.request_date > '2009-08-23%' and Calls.request_date < '2009-12-24%'");
	$fa09moodletotal = mysql_result($fa09resultsmoodle, 0, 0);
	//campus card
	$fa09resultscc = mysql_query("select count(*) from Calls WHERE problem_type='24' AND Calls.request_date > '2009-08-23%' and Calls.request_date < '2009-12-24%'");
	$fa09cctotal = mysql_result($fa09resultscc, 0, 0);
	//sbcc wireless
	$fa09resultswireless = mysql_query("select count(*) from Calls WHERE problem_type='26' AND Calls.request_date > '2009-08-23%' and Calls.request_date < '2009-12-24%'");
	$fa09wirelesstotal = mysql_result($fa09resultswireless, 0, 0);
	//PL Error message in Browser
	$fa09resultsPLerror = mysql_query("select count(*) from Calls WHERE problem_type='7' AND Calls.request_date > '2009-08-23%' and Calls.request_date < '2009-12-24%'");
	$fa09PLerrortotal = mysql_result($fa09resultsPLerror, 0, 0);
	//sbcc Registration/Add problem
	$fa09resultsreg = mysql_query("select count(*) from Calls WHERE problem_type='8' AND Calls.request_date > '2009-08-23%' and Calls.request_date < '2009-12-24%'");
	$fa09regtotal = mysql_result($fa09resultsreg, 0, 0);
	//sbcc PL Problem - email, chat, etc
	$fa09resultsplprob = mysql_query("select count(*) from Calls WHERE problem_type='11' AND Calls.request_date > '2009-08-23%' and Calls.request_date < '2009-12-24%'");
	$fa09plprobtotal = mysql_result($fa09resultsplprob, 0, 0);
	//sbcc other
	$fa09resultsother = mysql_query("select count(*) from Calls WHERE problem_type='13' AND Calls.request_date > '2009-08-23%' and Calls.request_date < '2009-12-24%'");
	$fa09othertotal = mysql_result($fa09resultsother, 0, 0);
	//sbcc PL account locked disabled
	$fa09resultspllocked = mysql_query("select count(*) from Calls WHERE problem_type='22' AND Calls.request_date > '2009-08-23%' and Calls.request_date < '2009-12-24%'");
	$fa09pllockedtotal = mysql_result($fa09resultspllocked, 0, 0);
	//sbcc PL Login 
	$fa09resultspllogin = mysql_query("select count(*) from Calls WHERE problem_type='18' AND Calls.request_date > '2009-08-23%' and Calls.request_date < '2009-12-24%'");
	$fa09pllogintotal = mysql_result($fa09resultspllogin, 0, 0);
	//sbcc SQ reset
	$fa09resultsplsq = mysql_query("select count(*) from Calls WHERE problem_type='21' AND Calls.request_date > '2009-08-23%' and Calls.request_date < '2009-12-24%'");
	$fa09plsqtotal = mysql_result($fa09resultsplsq, 0, 0);

?>
 <table width="50%" border="1" cellpadding="2" cellspacing="0" bordercolor="#000000">
   <tr>
     <td colspan="2"><span class="title">Statistics for Fall 09 - Problem Type &amp; Total number of emails for <strong>(8-23-09 to 12-24-09)</strong></span></td>
   </tr>
   <tr>
     <td width="64%">Moodle Technical Issue</td>
     <td width="36%"><?php echo $fa09moodletotal ?></td>
   </tr>
   <tr>
     <td>Campus Card</td>
     <td><?php echo $fa09cctotal ?></td>
   </tr>
   <tr>
     <td>SBCC Wireless</td>
     <td><?php echo $fa09wirelesstotal ?></td>
   </tr>
   <tr>
     <td>Error Message in Browser - Pipeline</td>
     <td><?php echo $fa09PLerrortotal ?></td>
   </tr>
   <tr>
     <td>Registration/Add Problem</td>
     <td><?php echo $fa09regtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Problem (email, groups, chat, ect)</td>
     <td><?php echo $fa09plprobtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Account Locked or Disabled</td>
     <td><?php echo $fa09pllockedtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Secret Question Resets</td>
     <td><?php echo $fa09plsqtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Login Problem</td>
     <td><?php echo $fa09pllogintotal ?></td>
   </tr>
   <tr>
     <td>Other</td>
     <td><?php echo $fa09othertotal ?></td>
   </tr>
 </table>
 <br>
<?php

//begin queries for number of calls, emails by problem type
	//moodle
	$su09resultsmoodle = mysql_query("select count(*) from Calls WHERE problem_type='23' AND Calls.request_date > '2009-05-20%' and Calls.request_date < '2009-08-22%'");
	$su09moodletotal = mysql_result($su09resultsmoodle, 0, 0);
	//campus card
	$su09resultscc = mysql_query("select count(*) from Calls WHERE problem_type='24' AND Calls.request_date > '2009-05-20%' and Calls.request_date < '2009-08-22%'");
	$su09cctotal = mysql_result($su09resultscc, 0, 0);
	//sbcc wireless
	$su09resultswireless = mysql_query("select count(*) from Calls WHERE problem_type='26' AND Calls.request_date > '2009-05-20%' and Calls.request_date < '2009-08-22%'");
	$su09wirelesstotal = mysql_result($su09resultswireless, 0, 0);
	//PL Error message in Browser
	$su09resultsPLerror = mysql_query("select count(*) from Calls WHERE problem_type='7' AND Calls.request_date > '2009-05-20%' and Calls.request_date < '2009-08-22%'");
	$su09PLerrortotal = mysql_result($su09resultsPLerror, 0, 0);
	//sbcc Registration/Add problem
	$su09resultsreg = mysql_query("select count(*) from Calls WHERE problem_type='8' AND Calls.request_date > '2009-05-20%' and Calls.request_date < '2009-08-22%'");
	$su09regtotal = mysql_result($su09resultsreg, 0, 0);
	//sbcc PL Problem - email, chat, etc
	$su09resultsplprob = mysql_query("select count(*) from Calls WHERE problem_type='11' AND Calls.request_date > '2009-05-20%' and Calls.request_date < '2009-08-22%'");
	$su09plprobtotal = mysql_result($su09resultsplprob, 0, 0);
	//sbcc other
	$su09resultsother = mysql_query("select count(*) from Calls WHERE problem_type='13' AND Calls.request_date > '2009-05-20%' and Calls.request_date < '2009-08-22%'");
	$su09othertotal = mysql_result($su09resultsother, 0, 0);
	//sbcc PL account locked disabled
	$su09resultspllocked = mysql_query("select count(*) from Calls WHERE problem_type='22' AND Calls.request_date > '2009-05-20%' and Calls.request_date < '2009-08-22%'");
	$su09pllockedtotal = mysql_result($su09resultspllocked, 0, 0);
	//sbcc PL Login 
	$su09resultspllogin = mysql_query("select count(*) from Calls WHERE problem_type='18' AND Calls.request_date > '2009-05-20%' and Calls.request_date < '2009-08-22%'");
	$su09pllogintotal = mysql_result($su09resultspllogin, 0, 0);
	//sbcc SQ reset
	$su09resultsplsq = mysql_query("select count(*) from Calls WHERE problem_type='21' AND Calls.request_date > '2009-05-20%' and Calls.request_date < '2009-08-22%'");
	$su09plsqtotal = mysql_result($su09resultsplsq, 0, 0);

?>
 <table width="50%" border="1" cellpadding="2" cellspacing="0" bordercolor="#000000">
   <tr>
     <td colspan="2" class="title">Statistics for Summer 09 - Problem Type &amp; Total number of emails for <strong>(5-20-09- 8-22-09)</strong></td>
   </tr>
   <tr>
     <td width="64%">Moodle Technical Issue</td>
     <td width="36%"><?php echo $su09moodletotal ?></td>
   </tr>
   <tr>
     <td>Campus Card</td>
     <td><?php echo $su09cctotal ?></td>
   </tr>
   <tr>
     <td>SBCC Wireless</td>
     <td><?php echo $su09wirelesstotal ?></td>
   </tr>
   <tr>
     <td>Error Message in Browser - Pipeline</td>
     <td><?php echo $su09PLerrortotal ?></td>
   </tr>
   <tr>
     <td>Registration/Add Problem</td>
     <td><?php echo $su09regtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Problem (email, groups, chat, ect)</td>
     <td><?php echo $su09plprobtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Account Locked or Disabled</td>
     <td><?php echo $su09pllockedtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Secret Question Resets</td>
     <td><?php echo $su09plsqtotal ?></td>
   </tr>
   <tr>
     <td>Pipeline Login Problem</td>
     <td><?php echo $su09pllogintotal ?></td>
   </tr>
   <tr>
     <td>Other</td>
     <td><?php echo $su09othertotal ?></td>
   </tr>
 </table>
 <br>
 
 
 
 <p class="title">Statistics for Problem Type by Date:</p>
<form method="post" action="stats.php">
 <input name="post" type="hidden" value="1">
   <select  name="problem_type" id="problem_type" value="">
         <option value="">Select problem type(s)...</option>
         <?php
		 $problem = mysql_query("select * from problem_type");
		 while($problemresults = mysql_fetch_array($problem)) {
		 echo "<option value=\"".$problemresults[PT_ID]."\">".$problemresults[PT_desc]. "</option>\n";
	      }
	     ?>
   </select>
   <br>
   <span class="normal">From: (Midnight on</span> 
  <select name="startMonth" id="startMonth">
   <option value="01" selected>January</option>
   <option value="02">Febuary</option>
   <option value="03">March</option>
   <option value="04">April</option>
   <option value="05">May</option>
   <option value="06">June</option>
   <option value="07">July</option>
   <option value="08">August</option>
   <option value="09">September</option>
   <option value="10">October</option>
   <option value="11">November</option>
   <option value="12">December</option>
 </select>
 <select name="startDay" id="startDay">
   <option value="1" selected>1</option>
   <option value="2">2</option>
   <option value="3">3</option>
   <option value="4">4</option>
   <option value="5">5</option>
   <option value="6">6</option>
   <option value="7">7</option>
   <option value="8">8</option>
   <option value="9">9</option>
   <option value="10">10</option>
   <option value="11">11</option>
   <option value="12">12</option>
   <option value="13">13</option>
   <option value="14">14</option>
   <option value="15">15</option>
   <option value="16">16</option>
   <option value="17">17</option>
   <option value="18">18</option>
   <option value="19">19</option>
   <option value="20">20</option>
   <option value="21">21</option>
   <option value="22">22</option>
   <option value="23">23</option>
   <option value="24">24</option>
   <option value="25">25</option>
   <option value="26">26</option>
   <option value="27">27</option>
   <option value="28">28</option>
   <option value="29">29</option>
   <option value="30">30</option>
   <option value="31">31</option>
  </select>
 <select name="startYear" id="startYear">
   <option value="2010" selected>2010</option>
   <option value="2009">2009</option>
   <option value="2008">2008</option>
   <option value="2007">2007</option>
  </select>
 <span class="normal"> )
  to (Midnight on</span> 
 <select name="endMonth" id="endMonth">
    <option value="01" selected>January</option>
    <option value="02">Febuary</option>
    <option value="03">March</option>
    <option value="04">April</option>
    <option value="05">May</option>
    <option value="06">June</option>
    <option value="07">July</option>
    <option value="08">August</option>
    <option value="09">September</option>
    <option value="10">October</option>
    <option value="11">November</option>
    <option value="12">December</option>
  </select>
  <select name="endDay" id="endDay">
    <option value="1" selected>1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    <option value="10">10</option>
    <option value="11">11</option>
    <option value="12">12</option>
    <option value="13">13</option>
    <option value="14">14</option>
    <option value="15">15</option>
    <option value="16">16</option>
    <option value="17">17</option>
    <option value="18">18</option>
    <option value="19">19</option>
    <option value="20">20</option>
    <option value="21">21</option>
    <option value="22">22</option>
    <option value="23">23</option>
    <option value="24">24</option>
    <option value="25">25</option>
    <option value="26">26</option>
    <option value="27">27</option>
    <option value="28">28</option>
    <option value="29">29</option>
    <option value="30">30</option>
    <option value="31">31</option>
  </select>
  <select name="endYear" id="endYear">
    <option value="2010" selected>2010</option>
    <option value="2009">2009</option>
    <option value="2008">2008</option>
    <option value="2007">2007</option>
  </select>
  )
  <input type="submit" name="Submit" value="Submit">
</form>
<p>
 <?php
 if ($_POST["post"] == '1') {
 	$resultcount = '0';
	
	// Setting up the SQL Query
 	$startDate=$_POST["startYear"].'-'.$_POST["startMonth"].'-'.$_POST["startDay"];
	//Fix the issue where selecting same date for start & end will return no results..
	$endday = $_POST["endDay"];
	$endDate=$_POST["endYear"].'-'.$_POST["endMonth"].'-'.$endday.'';
 	$query="SELECT * FROM `Calls` WHERE `request_date` BETWEEN '".$startDate."%' AND '".$endDate."%'";
	// If problem type is chosen, add to query
	if ($_POST["problem_type"]) {
		$query .= " AND `problem_type`='".$_POST["problem_type"]."'";
		}
	
	//Query the DB & Format Results
	$result = mysql_query($query);
	while ($row = mysql_fetch_array($result)) {
		$resultcount++;
		//For each row selected, format it into HTML.
		if ($resultcount & 1) { $bgcolor=' bgcolor="#CCCCCC"'; }
		else { $bgcolor=" bgcolor=''"; }
		
		$results .="<tr".$bgcolor."><td>".$row['first_name']." ".$row['m_initial']." ".$row['last_name']."</td><td>".$row['email']."</td><td>".$row['pipeline_userid']."</td><td>".$row['request_date']."</td></tr>\n";
		$results .="<tr".$bgcolor."><td colspan='3'>".reverseProbtype($row['problem_type'])."</td><td><a href='calls_detail.php?callid=".$row['Call_ID']."'>View Details</a></td></tr>\n";
	}
	//Print Results
	echo "<p class=bigred>Search Results:</p>";
	echo "<p class=normal>Query: ".$query."<br>";
	echo "<b>Results:</b> ".$resultcount."</p>";
}
 ?> 
 </p>
 <table width="650" border="=" cellpadding="2" cellspacing="2">
 <? echo($results); ?>

 </table>
 <p>&nbsp;</p>
 <p><a href="index.php">Back to Main Menu</a></p>
 </div>
</body>
</html>
